package com.xy.config;

import com.xy.bean.Person;
import com.xy.filter.MyTypeFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/4/6 15:32
 * @description 配置类 代替 配置文件
 */


@ComponentScan(value = "com.xy"
        // 不包含
        //,excludeFilters = {
        // @ComponentScan.Filter(type= FilterType.ANNOTATION,
        // classes = {Controller.class, Service.class})}

        // 包含
        // ,useDefaultFilters = false,
        // includeFilters = {
        // @ComponentScan.Filter(type = FilterType.ANNOTATION,
        // classes = {Controller.class})}

        // 自定义
        ,useDefaultFilters = false,includeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM,
         classes = {MyTypeFilter.class})}
)
@Configuration // 告诉spring 这是一个配置类
public class MainConfig {

    /**
     * id 为方法名
     * value 手动设置(指定)方法名
     */
    @Bean(value = "personMarry")
    public Person person01() {
        return new Person("marry", 21);
    }
}
